<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1{
            height: 400px;
            width: 400px;
            border: 1px solid #000;
            position: relative;
        }
        .inner1{
            height: 100px;
            width: 100px;
            background-color: pink;
            position: absolute;
            left: 50%;
            top: 50%;
            /* 位移自身的一半 */
            transform: translate(-50%,-50%);
        }
        .inner2{
            height: 100px;
            width: 100px;
            background-color: pink;
            position: absolute;
            left: -50px;
            top: -50px;
            margin: 50%;
        }
    </style>
</head>
<body>
    <div class="box1">
        <div class="inner1"></div>
    </div>
    <div class="box1">
        <div class="inner2"></div>
    </div>
</body>
</html>